//
//  CloudDoctorReserveController.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/26.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

class CloudDoctorReserveController: BaseViewController {
    
    private var doctorType: DoctorType
    
    init(with doctorType: DoctorType = .all) {
        self.doctorType = doctorType
        super.init(nibName: nil, bundle: nil)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    private lazy var searchVc: SearchViewController = {
//        let resultVc = DoctorLIstResultViewController()
//        let vc = SearchViewController(searchResultsController: resultVc)
//        vc.searchBar.delegate = self
//        return vc
//    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        setupNavBar()
        setupPageStyle()
    }
    
    private func setupPageStyle() {
        var style = PageViewStyle()
        style.isTitleScaleEnabled = true
        style.titleSelectedColor = .mainColor
        style.titleNormalColor = .textDark
        style.isContentViewScrollEnabled = true
        style.titleFont = .medium(16)

        let titles = ["云门诊"] //, "院内挂号"]
        let dateVc = DateReserveController(with: .cloud)
//        let doctorVc = BaseViewController()
        
        let vcs = [dateVc] //, doctorVc]
        for vc in vcs {
            self.addChild(vc)
        }
        let rect = CGRect(x: 0, y: navBarH, width: screenW, height: screenH - navBarH)
        let pageView = PageView(frame: rect,
                                style: style,
                                titles: titles,
                                childViewControllers: vcs)
        view.addSubview(pageView)
    }
    
    private func setupNavBar() {
        title = "找医生"
        createRightBarBtnItem(imageName: "nav_search", action: #selector(presentSearchVc))
    }
    
    @objc private func presentSearchVc() {
        let resultVc = DoctorLIstResultViewController(doctorType: doctorType)
        navigationController?.pushViewController(resultVc, animated: true)
    }
}
